var mapDataJson={
  "code": 200,
  "message": "成功",
  "timestamp": 1663557525,
  "signature": "6a361fb4b418e1f598aa71a702fcea8afc0e989b",
  "nonce": "V91ioM5vp1v2MLyg",
  "data": [
    {
      "name": "拉萨市",
      "value": 773,
      "areaCode": "540100",
      "reportMoney": "1063.21",
      "dealCode": null,
      "splxm": null,
      "balxm": null,
      "hzlxm": null,
      "hzze": null,
      "baze": null,
      "spze": null
    },
    {
      "name": "日喀则市",
      "value": 2158,
      "areaCode": "540200",
      "reportMoney": "1534.62",
      "dealCode": null,
      "splxm": null,
      "balxm": null,
      "hzlxm": null,
      "hzze": null,
      "baze": null,
      "spze": null
    },
    {
      "name": "昌都市",
      "value": 359,
      "areaCode": "540300",
      "reportMoney": "87.84",
      "dealCode": null,
      "splxm": null,
      "balxm": null,
      "hzlxm": null,
      "hzze": null,
      "baze": null,
      "spze": null
    },
    {
      "name": "林芝市",
      "value": 722,
      "areaCode": "540400",
      "reportMoney": "152.37",
      "dealCode": null,
      "splxm": null,
      "balxm": null,
      "hzlxm": null,
      "hzze": null,
      "baze": null,
      "spze": null
    },
    {
      "name": "山南市",
      "value": 203,
      "areaCode": "540500",
      "reportMoney": "149.57",
      "dealCode": null,
      "splxm": null,
      "balxm": null,
      "hzlxm": null,
      "hzze": null,
      "baze": null,
      "spze": null
    },
    {
      "name": "那曲市",
      "value": 278,
      "areaCode": "540600",
      "reportMoney": "43.78",
      "dealCode": null,
      "splxm": null,
      "balxm": null,
      "hzlxm": null,
      "hzze": null,
      "baze": null,
      "spze": null
    },
    {
      "name": "阿里地区",
      "value": 523,
      "areaCode": "542500",
      "reportMoney": "76.45",
      "dealCode": null,
      "splxm": null,
      "balxm": null,
      "hzlxm": null,
      "hzze": null,
      "baze": null,
      "spze": null
    }
  ]
};


var COLORS = ["#003167", "#0050a3", "#005fca", "#077fff", "#3fbcff", "#77d0ff"];
var option = {
  // backgroundColor: '#fff',
  // title: {
  //     text: '',
  //     top: 20,
  //     x: 'center',
  //     textStyle: {
  //         color: '#ccc'
  //     }
  // },
  tooltip: {
    trigger: 'item',
    formatter: function (params) {
      //return params.name + '<br />' + '项目数:' + params.value + '个' + '<br />' + '总投资:' + params.monery + '亿元';
      var res = params.name + '<br/>项目数：' + params.value + '个';
      var datas = option.series.data;
      for (var i = 0; i < datas.length; i++) {
        if (params.name == datas[i].name) {
          res = res + '<br/>总投资：' + datas[i].reportMoney + '亿元';
          break;
        }
      }
      return res;
    },
    textStyle: {
      color: '#fff'
    },
  },
  // grid: {
  //     left: '0%',
  //     right: '0%',
  //     bottom: '0%',
  //     top: '10%',
  //     containLabel: true
  // },
  title: {
    text: '投资项目在线审批监管平台申报项目概览',
    left: '30%',
    top: '0%',
    textStyle: {
      color: '#01479D',
      fontSize: 20
    }
  },
  // 视觉映射组件【展示效果类似于图例】
  visualMap: {
    // top bottom left right 组件离容器之间的距离
    type: 'piecewise',
    left: 50,
    bottom: 30,
    splitList: [
      {
        min: 1000,
        color: COLORS[0],
        label: '1000个以上'
      },
      {
        min: 301,
        max: 1000,
        color: COLORS[1],
        label: '301-1000个'
      },
      {
        min: 101,
        max: 300,
        color: COLORS[2],
        label: '101-300个'
      },
      {
        min: 21,
        max: 100,
        color: COLORS[3],
        label: '21-100个'
      },
      {
        min: 6,
        max: 20,
        color: COLORS[4],
        label: '6-20个'
      },
      {
        max: 5,
        color: COLORS[5],
        label: '5个或以下'
      }
    ],
  },
  geo: {
    roam: true, // 是否开启鼠标缩放
    // zoom: 1.5,// 当前视角的缩放比例
    // aspectScale: 0.75, // 地图的长宽比
    regions: [{
      label: {
        // show:true,
        // color: '#d87a80'
      }
    }]
  },
  series: {
    type: 'map',
    map: 'tibet',
    label: {
      show: true,
      color: '#cae5ff',
      fontSize: 12,
      position: 'top',
      align: 'left',
    },
    itemStyle: {
      borderColor: '#368de3',
    },
    emphasis: {
      label: {
        color: '#fff'
      },
      itemStyle: {
        borderColor: '#368de3',
        areaColor: '#fe9756',
        borderWidth: 0,
      }
    },
    data: null
  }
};

// 请求返回的数据
$(function () {
  getMapDates();
})

function getMapDates() {
  option.series.data = mapDataJson.data;
  var xizang_map = echarts.init(document.getElementById('xizang_map'));

  console.log('初始化')
    console.log(mapJson)
    echarts.registerMap('tibet', mapJson);
    xizang_map.setOption(option);

}
